From de86a98694b865b1abc8a40afbabb1e5efdf98fc Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 26 Apr 2023 10:21:59 -0700 Subject: [PATCH] add build date from CI. (#1087) --- gbversion.cmake | 8 ++++++++ gbversion.h.in | 1 + gui/aboutdlg.cc | 6 ++++++ gui/aboutdlg.h | 1 + gui/aboutui.ui | 1 + gui/mainwindow.cc | 7 ++++++- main.cc | 6 ++++++ 7 files changed, 29 insertions(+), 1 deletion(-) diff --git a/gbversion.cmake b/gbversion.cmake index 7ed8fc24c..6a7433649 100644 --- a/gbversion.cmake +++ b/gbversion.cmake @@ -24,6 +24,14 @@ list(GET VERSION_COMPONENTS 2 GB.MICRO) set(GB.BUILD 32 CACHE STRING "Fourth component of Windows VERSIONINFO resource FILEVERSION and PRODUCTVERSION parameters.") set(GB.PACKAGE_RELEASE "" CACHE STRING "String to append to VERSION tuple.") # .e.g. "-beta20190413" set(GB.SHA $ENV{GITHUB_SHA}) +if(DEFINED ENV{GITHUB_SHA}) + find_program(GIT_EXECUTABLE NAMES git) + if(NOT GIT_EXECUTABLE STREQUAL "GIT-NOTFOUND") + execute_process(COMMAND ${GIT_EXECUTABLE} show -s --format=%aI + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE GB.DATE OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() +endif() string(TIMESTAMP GB.COPYRIGHT_YEAR "%Y" UTC) # may be overridden on cmake command line diff --git a/gbversion.h.in b/gbversion.h.in index de72d684d..5334e826c 100644 --- a/gbversion.h.in +++ b/gbversion.h.in @@ -15,5 +15,6 @@ #else #define VERSION "@GB.MAJOR@.@GB.MINOR@.@GB.MICRO@@GB.PACKAGE_RELEASE@" constexpr char kVersionSHA[] = "@GB.SHA@"; +constexpr char kVersionDate[] = "@GB.DATE@"; #define WEB_DOC_DIR "https://www.gpsbabel.org/htmldoc-@DOCVERSION@" #endif diff --git a/gui/aboutdlg.cc b/gui/aboutdlg.cc index e98427924..4eb3539b4 100644 --- a/gui/aboutdlg.cc +++ b/gui/aboutdlg.cc @@ -30,6 +30,7 @@ AboutDlg::AboutDlg(QWidget* parent, const QString& ver1, const QString& ver2, const QString& ver3, + const QString& date, const QString& installationId): QDialog(parent) { ui_.setupUi(this); @@ -44,6 +45,11 @@ AboutDlg::AboutDlg(QWidget* parent, const QString& ver1, } else { tt.replace("$hash$", "Hash: " + ver3); } + if (date.isEmpty()) { + tt.replace("$date$", ""); + } else { + tt.replace("$date$", "Date: " + date); + } tt.replace("$installationId$", installationId); // Not localized as it should never be seen. diff --git a/gui/aboutdlg.h b/gui/aboutdlg.h index d20ca0af8..578d089e1 100644 --- a/gui/aboutdlg.h +++ b/gui/aboutdlg.h @@ -33,6 +33,7 @@ class AboutDlg: public QDialog public: AboutDlg(QWidget* parent, const QString& ver1, const QString& ver2, const QString& ver3, + const QString& date, const QString& installationId); private: diff --git a/gui/aboutui.ui b/gui/aboutui.ui index ae0d1b912..b96ed8495 100644 --- a/gui/aboutui.ui +++ b/gui/aboutui.ui @@ -89,6 +89,7 @@ p, li { white-space: pre-wrap; } <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(Using backend $babelversion$)</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$hash$</p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$date$</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">$upgradetestmode$</p> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Installation ID: $installationId$</p> <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> diff --git a/gui/mainwindow.cc b/gui/mainwindow.cc index 78b632b98..21352c239 100644 --- a/gui/mainwindow.cc +++ b/gui/mainwindow.cc @@ -1148,7 +1148,12 @@ void MainWindow::moreOptionButtonClicked() //------------------------------------------------------------------------ void MainWindow::aboutActionX() { - AboutDlg aboutDlg(nullptr, babelVersion_, QString(appName) + QString(" " VERSION), kVersionSHA, babelData_.installationUuid_); + QDateTime date = QDateTime::fromString(kVersionDate, Qt::ISODate); + QString utcdate; + if (date.isValid()) { + utcdate = date.toUTC().toString(Qt::ISODate); + } + AboutDlg aboutDlg(nullptr, babelVersion_, QString(appName) + QString(" " VERSION), kVersionSHA, utcdate, babelData_.installationUuid_); aboutDlg.setWindowTitle(tr("About %1").arg(appName)); aboutDlg.exec(); } diff --git a/main.cc b/main.cc index 3f5a08a91..9e90077ab 100644 --- a/main.cc +++ b/main.cc @@ -492,6 +492,12 @@ run(const char* prog_name) if(sizeof(kVersionSHA) > 1) { warning(MYNAME ": Repository SHA: %s\n", kVersionSHA); } + if(sizeof(kVersionDate) > 1) { + QDateTime date = QDateTime::fromString(kVersionDate, Qt::ISODate); + if (date.isValid()) { + warning(MYNAME ": Date: %s\n", qPrintable(date.toUTC().toString(Qt::ISODate))); + } + } warning(MYNAME ": Compiled with Qt %s for architecture %s\n", QT_VERSION_STR, qPrintable(QSysInfo::buildAbi())); -- 2.30.2